import time
def h(k):
    p = True
    while p:
        p = False
        for i in range (len(k) - 1):
            if k[i] > k[i+1]:
                k[i], k[i+1] = k[i+1], k[i]
                p=True
def read2list(m1_sorted):
    file = open(m1_sorted, 'r')
    data = file.readlines()
    return data
m1 = read2list('m1_sorted.txt')
m2 = read2list('m2_reverse.txt')
m3 = read2list('m3_shuffle.txt')
start = time.time()

h(m1)
t_finish = time.time()
print('m1_sorted', round(t_finish - start) * 1000, 'milliseconds')

h(m2)
start = time.time()
print('m2_reverse', round(t_finish - start) * -1000, 'milliseconds')

start = time.time()
h(m3)
t_finish = time.time()
print('m3_shuffle', round(t_finish - start) * 1000, 'milliseconds')
